home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-02-01 | 3.2 KB | 81 lines | [TEXT/CCL2] |
- ;-*- Mode: Lisp; Package: CCL -*-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; trace-step-gf-patch.lisp
- ;;copyright © 1992, 1993, Apple Computer, Inc.
-
- ; trace :step a generic function traces :step all his methods
- ; untrace a gf untraces the methods if so traced
-
- (in-package :ccl)
-
- (let ((*warn-if-redefine* nil)
- (*warn-if-redefine-kernel* nil))
-
-
- (defun %trace (sym &key before after step define-if-not)
- (let (def newdef trace-thing)
- (multiple-value-setq (def trace-thing)
- (%trace-function-spec-p sym define-if-not))
- (if def
- (let ()
- (when (%traced-p trace-thing)
- (%untrace-1 trace-thing)
- (setq def (%trace-fboundp trace-thing)))
- (when step ; just check if has interpreted def
- (if (typep def 'standard-generic-function)
- (let ((methods (%gf-methods def)))
- (dolist (m methods) ; stick :step-gf in advice-when slot
- (%trace m :step t)
- (let ((e (function-encapsulation m)))
- (when e (setf (encapsulation-advice-when e) :step-gf))))
- (if (or before after)
- (setq step nil)
- (return-from %trace)))
- (uncompile-for-stepping trace-thing nil t)))
- (let ((newsym (gensym "TRACE"))
- (method-p (typep trace-thing 'method)))
- (when (and (null before)(null after)(null step))
- (setq before #'trace-before)
- (setq after #'trace-after))
- (case before
- (:print (setq before #'trace-before)))
- (case after
- (:print (setq after #'trace-after)))
- (setq newdef (trace-global-def
- sym newsym before after step method-p))
- (when method-p
- (copy-method-function-bits def newdef))
- (without-interrupts
- (multiple-value-bind (ignore gf.dcode) (encapsulate trace-thing def 'trace sym newsym)
- (declare (ignore ignore))
- (cond (gf.dcode
- (setf (%gf-dcode def)
- (%cons-combined-method def (cons newdef gf.dcode) #'%%call-gf-encapsulation)))
- ((symbolp trace-thing) (%fhave trace-thing newdef))
- ((typep trace-thing 'method)
- (setf (%method-function trace-thing) newdef)
- (remove-obsoleted-combined-methods trace-thing)
- newdef))))))
- (report-bad-arg sym '(satisfies %trace-function-spec-p)))))
-
-
- (defun %untrace (sym)
- (when (and (consp sym)(consp (car sym)))
- (setq sym (car sym)))
- (multiple-value-bind (def trace-thing) (%trace-function-spec-p sym)
- (let (val)
- (when (typep def 'standard-generic-function)
- (let ((methods (%gf-methods def)))
- (dolist (m methods)
- (let ((e (function-encapsulation m)))
- (when (and e (eq (encapsulation-advice-when e) :step-gf))
- (remove-encapsulation e)
- (push m val))))))
- ; gf could have first been traced :step, and then just plain traced
- (when (%traced-p trace-thing)
- (%untrace-1 trace-thing)
- (push trace-thing val))
- (if (null (cdr val))(car val) val))))
- )
-
-